package com.sk.sourcecircle.adapter;

import android.support.annotation.Nullable;
import android.view.View;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.sk.sourcecircle.R;
import com.sk.sourcecircle.entity.GroupListBean;

import java.util.List;

/**
 * Created by sk on 2017/12/13.
 */

public class GroupListAdapter extends BaseQuickAdapter<GroupListBean.DataBean, BaseViewHolder> {

    public GroupListAdapter(int layoutResId, @Nullable List<GroupListBean.DataBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, GroupListBean.DataBean item) {
        Glide.with(mContext).load(item.getCommunity_image()).into((ImageView) helper.getView(R.id.item_bg));
        helper.setText(R.id.tv_name, item.getCommunity_name())
                .setText(R.id.tv_info, "介绍："+item.getIntroduce())
                .setText(R.id.tv_distance, String.valueOf(item.getDistance())+"km内")
                .addOnClickListener(R.id.item_bg)
                .addOnClickListener(R.id.add_care).addOnClickListener(R.id.cancel_care);
        if (item.getFollow() == 1) {
            helper.setGone(R.id.cancel_care, true);
            helper.setGone(R.id.add_care, false);
        } else {
            helper.setGone(R.id.cancel_care, false);
            helper.setGone(R.id.add_care, true);
        }

        ImageView imageView = helper.getView(R.id.vip);
        switch (item.getType()){
            case 1:
                imageView.setVisibility(View.VISIBLE);
                imageView.setImageResource(R.mipmap.group_vip);
                break;
            case 2:
                imageView.setVisibility(View.VISIBLE);
                imageView.setImageResource(R.mipmap.vip_icon);
                break;
            case 3:
                imageView.setVisibility(View.VISIBLE);
                imageView.setImageResource(R.mipmap.person_vip);
                break;
        }
    }
}
